<template>
	<transition name='fade'>
		<div class='search'>
			<Form ref="formInline" class='form' :model="formInline">
		       <div class='form-wrap'>
				 <h2 style='color: #fff; font-size: 22px; text-align:center; margin-bottom: 20px'>查询入口</h2>
		       	 <FormItem prop="user">
		            <Input type="text" v-model="formInline.id" placeholder="请输入身份证">
		                <Icon type="ios-person-outline" slot="prepend"></Icon>
		            </Input>
		        </FormItem>
		        <FormItem class='submit'>
		            <Button type="success" @click="handleSubmit('formInline')">点我查询</Button>
		        </FormItem>
		       </div>
		    </Form>

			<prompt :prompt="prompt" @close="close"></prompt>
		</div>
	</transition>
</template>

<script>
	import Prompt     		from 'base/prompt'

	export default{
		components: {
			Prompt
		},
		data () {
            return {
                formInline: {
                    id: '',
                },
                prompt        		: {
					hidden	  		: false,
					loading   		: false,
					name      		: '王锦佳',
					idcard        	: '46546546879798533566',
					address 	  	: '',
					age		  		: '',
					classname 	  	: '',
					dormitory 	  	: '',
					dormitorygrade	: '',
					dormitory 		: '',
					insurance 		: '',
					prove 			: '',
					report 			: '',
					sick 	 		: '',
					spename 		: '',
					studentid 		: '',
					studentname 	: '',
					studentnumber 	: '',
					studentsex 		: ''
				},
            }
        },
        methods: {
            handleSubmit(name) {
            	let passwordRule 		= /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
            	let params 	     		= this.formInline
				// if(!usernameRule.test(params.username)) {
				// 	this.$Message.error('请输入格式正确的用户名')
				// 	return
				// }
				if(!passwordRule.test(params.id)){
					this.$Message.error('请输入格式正确的身份证')
					return 
				}


            	let prompt    = this.prompt
            		prompt.loading   = !0
                setTimeout(() => {
                	prompt.loading   = !1
                	this.HttpService.GStudent({id: params.id}).then(data => {
                		params.id 		= ''
                		let d 			= data.data
	                	if(!data.status) {
	                		this.prompt = Object.assign(this.prompt, d)
                			prompt.hidden    = !0
	                	} else {
	                		this.$Message.error(data.msg)	
	                	}
	                	console.log(this.prompt)
	                })
                }, 1000)
            },
            close() {
            	this.prompt.hidden = !1
            }
        }
	}
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
	@import "~@/common/stylus/variable.styl"
	@import "~@/common/stylus/mixin.styl"
	
	.search
		position: absolute
		left: 0
		top: 0
		bottom: 0
		right: 0

	.form
		width: 60%
		height: 100%
		margin: 0 auto
		display: flex
		flex-direction: column
		justify-content: center
	.submit
		text-align: center
		

	.move-enter-active, .move-leave-active
		transition: 0.4s ease	
	.move-enter
		transform: translate3d(100%, 0, 0)
	.move-leave
		transform: translate3d(0, 0, 0) 
</style>